package com.guodx.study.springboot.d04.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class Hello {

    @ResponseBody
    @GetMapping("/hello/{name}")
    public String hello(@PathVariable("name") String name){
        return "hello, " + name;
    }


    /**
     * 返回/index.jsp页面
     * @param model
     * @return
     */
    @GetMapping("/hello-jsp")
    public String jsp(Model model){
        model.addAttribute("data", "Hello, Jsp");
        return "index";
    }

}
